package world.liuru.poem.service.impl;

import org.springframework.stereotype.Service;
import world.liuru.poem.entity.Picture;
import world.liuru.poem.repository.PictureRepository;
import world.liuru.poem.service.PictureService;

import javax.annotation.Resource;
import java.util.List;
@Service
public class PictureServiceImpl implements PictureService {
    @Resource
    PictureRepository pictureRepository;
    @Override
    public Picture insertPicture(Picture picture) {
        return pictureRepository.save(picture);
    }

    @Override
    public void deletePicture(String id) {
        pictureRepository.deleteById(id);
    }

    @Override
    public Picture updatePicture(Picture picture) {
        return pictureRepository.save(picture);
    }

    @Override
    public List<Picture> findAllPicture() {
        return pictureRepository.findAll();
    }

    @Override
    public Picture findPictureById(String id) {
        return pictureRepository.findById(id).orElse(null);
    }
}
